feat(auth): password-policy & session settings — live, enforced (P0 security)#2011
Merged
Conversation
…ecurity)
Extends the existing `auth` settings manifest (global scope) with the security
keys that are genuinely enforced today, instead of a new `security` namespace
full of non-functional toggles (false surface).
- Password policy: password_min_length (8), password_max_length (128) —
enforced by better-auth on sign-up / password reset.
- Sessions: session_expiry_days (7), session_refresh_days (1).
Rides the existing AuthPlugin.bindAuthSettings → AuthManager.applyConfigPatch
path (read on kernel:ready, re-applied live via settings.subscribe('auth'),
which invalidates the cached better-auth instance). Days → seconds for
session.{expiresIn,updateAge}; unset/malformed values ignored so the provider
default holds. en + zh-CN translations.
Out of scope (no enforcement → not declared): MFA-required, IP allowlist,
SSO/SAML, SCIM, API rate limits, password complexity/rotation/history.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📓 Docs Drift CheckThis PR changes 2 package(s): 14 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
P0 base-settings, item 3 of 3. Per the agreed scope, this extends the existing
authmanifest with the security-policy keys that are genuinely enforced today — rather than standing up asecuritynamespace full of non-functional toggles (IP allowlist / SSO / SCIM / rate-limit), which would be false surface and trip the platform's own liveness gate.What's added (all live)
Existing
authmanifest (global scope), new groups:password_min_length(default 8),password_max_length(default 128). better-auth enforces these on sign-up and password reset.session_expiry_days(default 7, absolute lifetime),session_refresh_days(default 1, refresh threshold).How they take effect (existing tested path)
They ride
AuthPlugin.bindAuthSettings→AuthManager.applyConfigPatch:settingsservice onkernel:readyand re-applied live viasettings.subscribe('auth').applyConfigPatchdeep-merges into config and nulls the cached better-auth instance, so the next request rebuilds with the new policy.session.{expiresIn,updateAge}. Unset (source: 'default') and malformed/non-positive values are ignored so the provider default holds.Deliberately out of scope (no enforcement exists → NOT declared)
MFA-required, IP allowlist, SSO/SAML, SCIM, API rate limits, password complexity/rotation/history. These are real features to build, not settings toggles. Recorded so the gap is explicit.
Tests
auth.manifest.test.ts— new number fields parse with bounds/defaults;password_policy/sessionsgroups present.auth-plugin.test.ts— bindAuthSettings applies length bounds + session lifetime (days→seconds); ignores default-source and malformed/non-positive values.P0 complete
localization(feat(settings): localization settings — platform timezone/language/formats (ADR-0053 Phase 2) (#1928) #2006). 2. ✅company(feat(settings): company settings — legal organization identity (P0) #2010). 3. this PR auth security policy.🤖 Generated with Claude Code